package offer;

import java.util.HashMap;

public class Offer39 {

    public  int find(int[] nums){
        int length = nums.length;
        int target=length/2;

        if(length==1){
            return nums[0];
        }
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < length; i++) {
            if (!map.containsKey(nums[i])){
                map.put(nums[i],1 );
            }else {
                Integer integer = map.get(nums[i])+1;
                if (integer>target){
                    return  nums[i];
                }
                map.put(nums[i],integer);
            }
            
        }
        return  -1;
    }




}
